package com.ck.ckcloud.networkmanagement.infrastructure.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ck.ckcloud.networkmanagement.domain.entity.Resource;
import com.ck.ckcloud.networkmanagement.infrastructure.persistence.DO.ResourceDO;
import com.ck.ckcloud.networkmanagement.infrastructure.persistence.mapper.ResourceMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


/**
 * 网管资源仓储
 *
 * @author Aiden <a href="mailto:adam602260@gmail.com"/>
 * @version ResourceRepository.java v0.1
 * @create 2019-09-17 21:55
 */
@Repository
public class ResourceRepository extends ServiceImpl<ResourceMapper, ResourceDO> {

	@Autowired
	private ResourceMapper resourceMapper;

	/**
	 * 根据资源唯一ID查找一个资源
	 * @param uniqueId
	 * @return
	 */
	public ResourceDO getByUniqueId(String uniqueId){

		ResourceDO resourceDO = super.getOne(
				Wrappers.<ResourceDO>query()
					.lambda()
					.eq(ResourceDO::getResourceuniqueid, uniqueId));
		return resourceDO;
	}

	/**
	 * 分页查询
	 *
	 * @param page
	 * @return
	 */
	public IPage listByPage(Page page) {
		return super.page(page, Wrappers.emptyWrapper());
	}

}
